package com.itheima.project.feign;

import com.itheima.project.basic.ResponseWrap;
import com.itheima.project.hystrix.UserAdapterHtstrix;
import com.itheima.project.vo.security.ResourceVo;
import com.itheima.project.vo.security.RoleVo;
import com.itheima.project.vo.security.UserVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * @Description：用户权限适配服务接口定义
 */
@FeignClient(value = "module-security-web",fallback = UserAdapterHtstrix.class)
public interface UserAdapterFeign {

    /**
     * @Description 按用户名查找用户
     * @param username 登录名
     * @return
     */
    @GetMapping("user-adapter/find-user-username-enterprise/{username}/{enterpriseId}")
    ResponseWrap<UserVo> findUserByUsernameAndEnterpriseId(@PathVariable("username") String username,
                                                           @PathVariable("enterpriseId") Long enterpriseId);

    /**
     * @Description 按用户手机查找用户
     * @param mobile 登录名
     * @return
     */
    @GetMapping("user-adapter/find-user-mobile-enterprise/{mobile}/{enterpriseId}")
    ResponseWrap<UserVo> findUserByMobileAndEnterpriseId(@PathVariable("mobile")String mobile,
                                           @PathVariable("enterpriseId")Long enterpriseId);

    /**
     * @Description 按微信openId查找客户
     * @param openId 登录名
     * @return
     */
    @GetMapping("user-adapter/find-user-openid-enterprise/{openId}/{enterpriseId}")
    ResponseWrap<UserVo> findUserByOpenIdAndEnterpriseId(@PathVariable("openId") String openId,
                                                         @PathVariable("enterpriseId")Long enterpriseId);
    /**
     * @Description 查找用户所有角色
     * @param userId 用户Id
     * @return
     */
    @GetMapping("user-adapter/find-role-user/{userId}")
    ResponseWrap<List<RoleVo>> findRoleByUserId(@PathVariable("userId")Long userId);

    /**
     * @Description 查询用户有资源
     * @param userId 用户Id
     * @return
     */
    @GetMapping("user-adapter/find-resoure-user/{userId}")
    ResponseWrap<List<ResourceVo>> findResourceByUserId(@PathVariable("userId")Long userId);

    /***
     * @description 查询当前用户
     * @param userId
     * @return
     */
    @GetMapping("user-adapter/find-cuttent-user/{userId}")
    ResponseWrap<UserVo> findCurrentUser(@PathVariable("userId")Long userId);

    /**
     * @Description 注册用户
     * @param userVo 对象信息
     * @return
     */
    @PostMapping("user")
    ResponseWrap<UserVo> registerUser(@RequestBody UserVo userVo);

}
